<?php
// 这是系统自动生成的公共文件


if (!function_exists("responses")){
    /**
     * 响应方法
     * @param $data
     * @param int $code
     * @param string $msg
     * @return \support\Response|\think\response\Json
     */
    function responses($data=[],$code=200,$msg='ok') {
        return json(['code' => $code,'data' => $data,'msg' => $msg]);
    }
}

/**
 * 密码加密
 */
if (!function_exists("encrypt_password")){
    /**
     * @param $password
     * @return string
     */
    function encrypt_password($password){
        return md5("abc" . $password . "adb");
    }
}

if (!function_exists("parent_child")){
    function parent_child($data,$pid=0){
        $res = [];
        foreach ($data as $key => $value) {
            if ($value['pid'] == $pid) {
                $res[$key] = $value;
                $res[$key]['children'] = parent_child($data,$value['id']);
            }
        }
        return $res;
    }
}
